<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
    <style>
      :root {
        /* --div-bg-color: yellowgreen; */
        div-bg-color: yellowgreen;
      }
      .app {
        height: 100vh;
        border: 1px solid #000000;
        --div-bg-color: pink;
        background-color: var(--div-bg-color);
      }
      .app > div {
        height: 50vh;
        border: 1px solid #000;
      }
      .item {
        --div-bg-color: purple;
        /* 找得到就用,找不到,依次逐级向上找 */
        /* background-color: var(--div-bg-color); */
        /* 找不到,不会报错,不生效 */
        /* background-color: var(--div-bgc-color); */
        background-color: var(div-bg-color);
      }
    </style>
  </head>
  <body>
    <div class="app">
      <div class="item"></div>
      <div class="box"></div>
    </div>
  </body>
</html>
